package cn.aylog.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

@Controller
public class HelloController {

    // 获取请求体参数
    @RequestMapping("/requestParam")
    @ResponseBody
    public String param1(@RequestParam("name") String name) {
        System.out.println(name);
        return "success";
    }

    // 获取请求头参数
    @RequestMapping("/requestHeader")
    @ResponseBody
    public String param2(@RequestHeader("Accept") String accept) {
        System.out.println(accept);
        return "success";
    }

    // 获取cookie
    @RequestMapping("/requestCookie")
    @ResponseBody
    public String param3(@CookieValue("JSESSIONID") String id) {
        System.out.println(id);
        return "success";
    }

    // RestFul风格参数获取
    @RequestMapping("/requestRestFul/{name}")
    @ResponseBody
    public String param4(@PathVariable("name") String name) {
        System.out.println(name);
        return "成功";
    }
}
